<template>
  <div>
    <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" v-loading="loading"></el-tree>
  </div>
</template>



<script>
import { getTree } from '@/service/swagger/DeptController.js'
import { getUserList } from '@/service/swagger/UserController.js'

export default {
  data() {
    return {
      data: [],
      loading: false,
      defaultProps: {
        children: 'children',
        label: 'text'
      }
    }
  },
  mounted() {
    this.getDepData()
  },
  methods: {
    //获取部门菜单树
    getDepData() {
      this.loading = true
      getTree({}).then(ret => {
        this.loading = false
          if(ret&&ret.code == 0){
            console.log(ret)
            if(ret.data.id == '-1'){
              this.data = ret.data.children
            }else{
               this.data.push(ret.data)
            }
          }
        })
      },
      //根据部门获取部门用户信息
      handleNodeClick(data) {
        this.$emit('handleGetUserByDep',data)
      }
    }
  
}
</script>